import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter_demo/models/home_model.dart';
import 'package:flutter_demo/utils/DioUtils.dart';
import 'package:fluttertoast/fluttertoast.dart';


class HomeDao {

  static String _url = "https://cdn.lishaoy.net/ctrip/homeConfig.json";

  // 获取首页数据
  static HomeModel fetch() {
    HomeModel model;
    DioUtils.postHttp(
        _url,
        onSuccess: (data) {
          model =  HomeModel.fromJson(json.decode(data));
        },
        onError: (error) {
          Fluttertoast.showToast(msg: error.toString());
          model = null;
        }
    );
    return model;
  }
}